/*
=======================================================================

  BOTS Sniper Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_SNIPER_ALARM			120
#define BOTS_SNIPER_ALARMKILL		121
#define BOTS_SNIPER_SENDALARM		122
#define BOTS_SNIPER_SIGHT			123
#define BOTS_SNIPER_TRACKER			124
#define BOTS_SNIPER_FLARE			125
#define BOTS_SNIPER_CLOAK			126
#define BOTS_SNIPER_CLOAKWALK		127

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	alarm;
  menutext_s	alarmkill;
  menutext_s	sendalarm;
  menutext_s	sight;
  menutext_s	tracker;
  menutext_s	flare;
  menutext_s	cloak;
  menutext_s	cloakwalk;
  menutext_s	cancel;
} sniperCommands_t;

static sniperCommands_t		s_sniper;

/*
=================
BOTS_SniperCommandsMenu_Event
callback routine
=================
*/
void BOTS_SniperCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_SNIPER_ALARM:
		trap_Cmd_ExecuteText( EXEC_APPEND, "alarm\n" );
		break;
	case BOTS_SNIPER_ALARMKILL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "alarmkill\n" );
		break;
	case BOTS_SNIPER_SENDALARM:
		trap_Cmd_ExecuteText( EXEC_APPEND, "sendalarm\n" );
		break;
	case BOTS_SNIPER_SIGHT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "sight\n" );
		break;
	case BOTS_SNIPER_TRACKER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "tracker\n" );
		break;
	case BOTS_SNIPER_FLARE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "flare\n" );
		break;
	case BOTS_SNIPER_CLOAK:
		trap_Cmd_ExecuteText( EXEC_APPEND, "cloak\n" );
		break;
	case BOTS_SNIPER_CLOAKWALK:
		trap_Cmd_ExecuteText( EXEC_APPEND, "cloakwalk\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_SniperCommandsMenu_Init
=================
*/
void BOTS_SniperCommandsMenu_Init() 
{
	int y;

	memset( &s_sniper, 0 ,sizeof(sniperCommands_t) );
	s_sniper.menu.wrapAround = qtrue;
	s_sniper.menu.fullscreen = qfalse;

	y = 96;
	s_sniper.title.generic.type		= MTYPE_PTEXT;
	s_sniper.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_sniper.title.generic.x		= 320;
	s_sniper.title.generic.y		= y;
	s_sniper.title.string			= "SNIPER COMMANDS MENU";
	s_sniper.title.color			= color_bots_menu;
	s_sniper.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.alarm.generic.type		= MTYPE_PTEXT;
	s_sniper.alarm.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.alarm.generic.x		= 320;
	s_sniper.alarm.generic.y		= y;
	s_sniper.alarm.generic.id		= BOTS_SNIPER_ALARM;
	s_sniper.alarm.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.alarm.string			= "SET ALARM - alarm";
	s_sniper.alarm.color			= color_bots_menu;
	s_sniper.alarm.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.alarmkill.generic.type		= MTYPE_PTEXT;
	s_sniper.alarmkill.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.alarmkill.generic.x		= 320;
	s_sniper.alarmkill.generic.y		= y;
	s_sniper.alarmkill.generic.id		= BOTS_SNIPER_ALARMKILL;
	s_sniper.alarmkill.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.alarmkill.string			= "DESTROY ALARMS - alarmkill";
	s_sniper.alarmkill.color			= color_bots_menu;
	s_sniper.alarmkill.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.sendalarm.generic.type		= MTYPE_PTEXT;
	s_sniper.sendalarm.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.sendalarm.generic.x		= 320;
	s_sniper.sendalarm.generic.y		= y;
	s_sniper.sendalarm.generic.id		= BOTS_SNIPER_SENDALARM;
	s_sniper.sendalarm.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.sendalarm.string			= "SEND ALARM - sendalarm";
	s_sniper.sendalarm.color			= color_bots_menu;
	s_sniper.sendalarm.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.sight.generic.type		= MTYPE_PTEXT;
	s_sniper.sight.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.sight.generic.x		= 320;
	s_sniper.sight.generic.y		= y;
	s_sniper.sight.generic.id		= BOTS_SNIPER_SIGHT;
	s_sniper.sight.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.sight.string			= "USE LASER SIGHT - sight";
	s_sniper.sight.color			= color_bots_menu;
	s_sniper.sight.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.tracker.generic.type		= MTYPE_PTEXT;
	s_sniper.tracker.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.tracker.generic.x			= 320;
	s_sniper.tracker.generic.y			= y;
	s_sniper.tracker.generic.id			= BOTS_SNIPER_TRACKER;
	s_sniper.tracker.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.tracker.string				= "USE TRACKER - tracker";
	s_sniper.tracker.color				= color_bots_menu;
	s_sniper.tracker.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.flare.generic.type		= MTYPE_PTEXT;
	s_sniper.flare.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.flare.generic.x		= 320;
	s_sniper.flare.generic.y		= y;
	s_sniper.flare.generic.id		= BOTS_SNIPER_FLARE;
	s_sniper.flare.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.flare.string			= "FIRE FLARE - flare";
	s_sniper.flare.color			= color_bots_menu;
	s_sniper.flare.style			= UI_CENTER|UI_SMALLFONT;

/*
	y += BOTS_VERTICAL_SPACING;
	s_sniper.cloak.generic.type		= MTYPE_PTEXT;
	s_sniper.cloak.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.cloak.generic.x		= 320;
	s_sniper.cloak.generic.y		= y;
	s_sniper.cloak.generic.id		= BOTS_SNIPER_CLOAK;
	s_sniper.cloak.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.cloak.string			= "INSTANT CLOAK - cloak";
	s_sniper.cloak.color			= color_bots_menu;
	s_sniper.cloak.style			= UI_CENTER|UI_SMALLFONT;
*/

	y += BOTS_VERTICAL_SPACING;
	s_sniper.cloakwalk.generic.type		= MTYPE_PTEXT;
	s_sniper.cloakwalk.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.cloakwalk.generic.x		= 320;
	s_sniper.cloakwalk.generic.y		= y;
	s_sniper.cloakwalk.generic.id		= BOTS_SNIPER_CLOAKWALK;
	s_sniper.cloakwalk.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.cloakwalk.string			= "MOBILE CLOAK - cloakwalk";
	s_sniper.cloakwalk.color			= color_bots_menu;
	s_sniper.cloakwalk.style			= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 4) {
		s_sniper.cloakwalk.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_sniper.cancel.generic.type		= MTYPE_PTEXT;
	s_sniper.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_sniper.cancel.generic.x			= 320;
	s_sniper.cancel.generic.y			= y;
	s_sniper.cancel.generic.id			= BOTS_CANCEL;
	s_sniper.cancel.generic.callback	= BOTS_SniperCommandsMenu_Event; 
	s_sniper.cancel.string				= "CANCEL";
	s_sniper.cancel.color				= color_bots_menu;
	s_sniper.cancel.style				= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_sniper.menu, &s_sniper.title );
	Menu_AddItem( &s_sniper.menu, &s_sniper.alarm );
	Menu_AddItem( &s_sniper.menu, &s_sniper.alarmkill );
	Menu_AddItem( &s_sniper.menu, &s_sniper.sendalarm );
	Menu_AddItem( &s_sniper.menu, &s_sniper.sight );
	Menu_AddItem( &s_sniper.menu, &s_sniper.tracker );
	Menu_AddItem( &s_sniper.menu, &s_sniper.flare );
//	Menu_AddItem( &s_sniper.menu, &s_sniper.cloak );
	Menu_AddItem( &s_sniper.menu, &s_sniper.cloakwalk );
	Menu_AddItem( &s_sniper.menu, &s_sniper.cancel );
}

void BOTS_SniperCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_SniperCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_sniper.menu );
}
